#include<iostream>
#include<format>
using namespace std;
int main(){
  int a,b,c=1;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    c=c*a%1000;
  }

  cout<<format("{:03d}",c);

  //printf("%03d",c);
}